<template>
	<view>
		<view v-if="examList.length === 0">
			<image style="width: 400rpx;height: 400rpx; position: absolute; left: 20%; top:20%"
				src="https://tj-1305380059.cos.ap-nanjing.myqcloud.com/pic/wujilu.png" mode=""></image>
		</view>
		<view v-else>
			<uni-card v-for="(item,index) in examList" :key="index"  padding="0" spacing="0">
				<uni-list :border="false">
					<uni-list-item :border="false" showArrow clickable @click="toExamDetailsPage(item.id)">
						<template v-slot:body>
							<view>考试名称：{{item.name}}</view>
							<view>考试时间：{{item.examDate === null ? '' : item.examDate}}</view>
						</template>
					</uni-list-item>
				</uni-list>
			</uni-card>
		</view>
	</view>
</template>

<script>
	import exam from '@/api/modules/exam';
	
	
	export default {
		data() {
			return {
				studentId : uni.getStorageSync("loginId"),
				examList : [],
			}
		},
		created() {
			this.getExam();
		},
		methods: {
			getExam() {
				uni.showLoading({
					mask: true,
					title: '加载中'
				});
				exam.getExam(this.studentId).then(res=> {
					uni.hideLoading();
					this.examList=res.data
				}).catch(err => {
					uni.hideLoading();
					uni.showToast({
						title: '加载失败,稍后重试...',
						icon: "error"
					})
				})
			},
			toExamDetailsPage(examId) {
				uni.navigateTo({
					url: `/pages_duty/parent/examDetail?examId=${examId}`
				})
			},
		}
	}
</script>

<style>
</style>
